<!--
    /**
     * 用户树形下拉选择组件：继承自树形下拉选择组件
     * @see @/components/TreeSelect
     * 使用方法
     * <human-user-chooser v-model="form.entry.parentId" :readonly="!form.editable" :disabled="!form.editable"></human-user-chooser>
     */
-->
<script>

import TreeSelect from "@/components/TreeSelect"
import *  as humanUserApi from '../apis/user'

export default {
  extends: TreeSelect,
  name: 'humanUserChooser',
  props: {
    nodeProps: {
      type: Object, default() {
        return {children: 'children', label: 'name',}
      }
    },
    nodeKey: {
      type: String, default() {
        return 'id'
      }
    },
  },
  data() {
    return {
      treeData: []
    };
  },
  created() {
    this.loadData()
  },
  mounted() {
  },
  methods: {
    loadData() {
      //if (!this.nodeData) {
        humanUserApi.tree().then(response => {
          let {status, result} = response
          if (status === 200) {
            result.map(entry => {
              entry.disable = entry.model === 'user' ? false : true
            })
            //this.treeData = this.$utils.listConvertTree(response.result)
            this.$set(this, "treeData", this.$utils.listConvertTree(response.result))
            //this.handleSelectedKey()
          }
        })
     // }
    }
  },
};
</script>

